﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using BrainTechLLC;
using BrainTechLLC.WPF;
using System.Windows.Data;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows;
using System.Collections.Specialized;
using DirectoryViewModels;
using System.Threading;
using BrainTechLLC.ThreadSafeObjects;

namespace BrainTechLLC.FolderExplorer
{
    public class FileViewModel : BaseNotifyPropertyChangedUI
    {
        protected FileInfo _File;
        protected long _Length;

        public FileInfo File
        {
            get { return _File; }
            set
            {
                if (_File != value)
                {
                    _File = value;
                    OnPropertyChanged("File");
                }
            }
        }

        public string Name { get { return _File.Name; } }

        public string FileSize
        {
            get
            {
                if (_File == null)
                {
                    return "N/A";
                }
                double d = (double)Length / 1024D;
                return d.ToString("N2") + "KB";                
            }
        }

        public string FileDate
        {
            get { return _File.CreationTime.ToShortDateString(); }
        }
        
        public long Length
        {
            get
            {
                if (_Length == 0)
                {
                    _Length = _File.Length;
                }
                return _Length;
            }
        }

        public FileViewModel()
        {
        }

        public FileViewModel(FileInfo fileInfo)
        {
            _File = fileInfo;
        }
    }
}
